#ifndef __QUEUE_BASE__
#define __QUEUE_BASE__

#include "define.h"
#include "inifile.h"
#include "httpqueue.h"

#include <pthread.h>

#define HANDLER_NUMBER 7

typedef struct _queue_status
{
	unsigned int position;
	int is_lock_r;
	int is_lock;
	int id_now;
	int id_next;
	int id_max;
}
queue_status;

typedef struct _queue_control
{
	Command cmd;
	char detail[8188];
}
queue_control;

typedef struct _queue_handler
{
	int wfd;
	int rfd;
	const char *name;
	const char *index;
}
queue_handler;

typedef struct _queue_thread
{
	pthread_t tid;
	size_t count;
	int runing;
}
queue_thread;

extern INI_Section *cfg;

extern queue_control *control;
extern queue_handler handler[];
extern queue_status* status[];

extern int   rqueue_lock[];
extern int   is_rqueue_lock[];

///////////////////////////////////
extern queue_status* stat_open(queue_status **st, const char* filename);
extern int   stat_close(queue_status *i_stat);

extern void  queue_header_init(queue_header *header);
extern int   queue_init_conf(const char *config);

extern int   queue_status_init();
extern int   queue_status_fini();

extern char* root_path(char *prog);

/////////////////////////////////////
extern int   rqueue_lock_init();
extern void  rqueue_lock_fini();

extern int   rqueue_read_lock(int index);
extern int   rqueue_read_unlock(int index);

extern int   rqueue_read_pause(int index);
extern int   rqueue_read_continue(int index);

#endif // __QUEUE_BASE__
